<template>
  <div>
    <a-card :bordered="false">
      <f-search-form :more="true" @searchHandler="searchHandler" :tableObj="tableObj" :show-export-btn='true' export-url='exportUrl2'>
        <f-search-form-item label="区域"  name="areaName"   type="select"      valueKey="areaName" label-key="areaName" style="width:220px"/>
        <f-search-form-item label="部门" ref="dept"  name="deptId" type="select" :data="api.dept.list"  valueKey="deptId" label-key="deptName" style="width:220px"/>
        <f-search-form-item label="单号" name="orderNo" style="width: 250px"/>
        <f-search-form-item label="发货日期(起)" type="date" name="beginDate" style="width: 250px"/>
        <a-tooltip title='导出实时数据,请点击该按钮' slot="btn">
          <a-button  style='margin-left: 3px' @click='clearExport' >清理缓存</a-button>
        </a-tooltip>
      </f-search-form>
      <f-table ref="table"  rowKey="orderDetailsId" :showSetting="true"  :tableColumns="columns" :scroll="{x:true}"  :multiple="false" :operator="operator" :params="queryParam" :api="api.bod" handler="orderDetailsReportHandler">
         <span slot="orderNo" slot-scope="text, record, index">
            <span v-clipboard:copy="text" v-clipboard:success="onCopy" style="cursor:pointer">{{text}}</span>
        </span>
        <span slot="saleType" slot-scope="text, record">
        <template>
        <span>
          <a-tag v-if="text=='CHA'" color="blue">销售</a-tag>
          <a-tag v-if="text=='CHC'" color="blue">退货</a-tag>
          <a-tag v-if="text==3" color="blue">补货</a-tag>
          <a-tag v-if="text==4" color="blue">票折</a-tag>
        </span>
        </template>
      </span>
        <span slot="action" slot-scope="text, record">
          <template>
             <a @click="$refs.orderInfoDrawer.showDrawer(record)" >查看</a>
          </template>
       </span>
      </f-table>
    </a-card>

  </div>
</template>
<script>
import api from './../../js/api'

export default {
  name: 'MingXiList',
  components: {

  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag=this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId:this.$store.state.user.companyId
      },
      tableObj:null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: '#',
          width: '70px',
          align: 'center',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '累计发货金额',
          align: 'left',
          width: '80px',
          dataIndex: 'salePrice'
        },
        {
          title: '累计回款金额',
          align: 'left',
          width: '80px',
          dataIndex: 'orderNo',
          scopedSlots: { customRender: 'orderNo' }
        },
        {
          title: '退货款',
          align: 'left',
          width: '80px',
          dataIndex: 'saleType'
        },
        {
          title: '应收金额',
          align: 'left',
          width: '90px',
          dataIndex: 'customReturnState',
        },
        {
          title: '保证金余额',
          align: 'left',
          width: '90px',
          dataIndex: 'settleState'
        },
        {
          title: '累计应结算金额',
          align: 'left',
          width: '100px',
          dataIndex: 'customBondState'
        },
        {
          title: '未结算金额',
          align: 'left',
          sorter: true,
          width: '100px',
          dataIndex: 'saleDate'
        },
        
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj=this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success('复制成功!')
    },
    initSettle(record){
      // this.http.confirm(this, {
      //   content: '确认初始化结算吗?',
      //   url: api.payment.initSettlePayment,
      //   data: {
      //     orderDetailsId: record.orderDetailsId
      //   }
      // })
    },
    clearExport(){
      this.http.post(this, {
        url: this.api.bod.clearExportData
      })
    }
  }
}
</script>
